Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C# / VB.NET - [C#] pulsante per eseguire un EXE
Forum - C# / VB.NET - [C#] pulsante per eseguire un EXE

Avatar
fosforo (Normal User)
Expert


Messaggi: 391
Iscritto: 06/04/2009

Segnala al moderatore
Postato alle 15:00
Giovedì, 19/03/2015
Ciao
Ho creato un pulsante per poter lanciare un eseguibile e leggerne il suo output:

private void button5_Click(object sender, EventArgs e)
        {
            ProcessStartInfo start = new ProcessStartInfo();
            start.FileName = "C:\\Program Files\\MediaInfo_CLI\\MediaInfo.exe" + "--help";
            //MessageBox.Show(openFileDialog1.FileName);
    start.UseShellExecute = false;
    start.RedirectStandardOutput = true;
    using (Process process = Process.Start(start))
    {
             using (StreamReader reader = process.StandardOutput)
        {
            string result = reader.ReadToEnd();
            MessageBox.Show (result);
        }
    }

Purtroppo si ferma sul  Process.Start(start)) dandomi:
Win32Exception non è gestita.

Non riesco a trovare la soluzione.

Grazie anticipatamente.

PM Quote
Avatar
fosforo (Normal User)
Expert


Messaggi: 391
Iscritto: 06/04/2009

Segnala al moderatore
Postato alle 15:30
Giovedì, 19/03/2015
Ciao
Ho risolto

Devo dare gli argomenti in questo modo:
    start.FileName = "C:\\Program Files\\MediaInfo_CLI\\MediaInfo.exe"
start.Arguments = " --Help";

PM Quote
Avatar
Ultimo (Member)
Guru


Messaggi: 882
Iscritto: 22/05/2010

Segnala al moderatore
Postato alle 15:33
Giovedì, 19/03/2015
usa il controllo delle eccezzioni



If ok Then GOTO Avanza else GOTO Inizia

PM Quote